# main.py
from app.database import init_db
from app.service.UserService import UserService


if __name__ == '__main__':
    # 初始化数据库
    init_db()

    service = UserService()
    # 1. 创建单个用户
    # user_id = service.create_user(
    #     username="tech_leader",
    #     email="tech@example.com"
    # )
    # print(f"创建用户ID: {user_id}")

    # 2. 查询用户
    user_data = service.get_user(1)
    print(f"查询结果: {user_data['username']}")

    # # 3. 批量插入（100条数据）
    # service.batch_create_users([
    #     (f"user_{i}", f"user_{i}@domain.com") for i in range(100)
    # ])

    # 4. 复杂查询
    results = service.search_users("user")
    print(f"搜索到 {len(results)} 个相关用户")

    users = service.get_all_user()
    for user in users:  # user 是 User 模型实例
        print(f"ID: {user.id}, 用户名: {user.username}")
